<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<f:view>
	<h:head></h:head>
	<h:body>
		<h:form>
			<h:panelGrid columns="1">
				<h:panelGrid id="baslikPanel" columns="4">
					<h:outputText value="Sipariş No" />
					<h:inputText value="#{siparisBean.siparis.siparisKodu}">
						<p:ajax event="blur"  listener="#{siparisBean.araSiparis}"
							update="baslikPanel"></p:ajax>
					</h:inputText>

					<h:outputText value="Durum" />
					<h:inputText value="#{siparisBean.siparis.durum}">
					</h:inputText>

					<h:outputText value="Sipariş Tarihi" />
					<p:calendar id="siparisTarihi" popupIcon=""
						value="#{siparisBean.siparis.siparisTarihi}"></p:calendar>


					<h:outputText value="Son Kayıt Tarihi" />

					<h:inputText id="sonKayitTarihi"
						value="#{siparisBean.siparis.sonKayitTarihi}">
						<f:convertDateTime pattern="dd/MM/yyyy"></f:convertDateTime>
					</h:inputText>

				</h:panelGrid>
				<h:panelGrid columns="2">
					<h:outputText value="Sipariş Açıklaması" />
					<h:inputTextarea id="aciklama"
						value="#{siparisBean.siparis.aciklama}" cols="40">
					</h:inputTextarea>

				</h:panelGrid>
			</h:panelGrid>
			<h:panelGrid columns="4" id="malzemeDetay">
				<h:outputText value="Malzeme Kodu" />
				<h:outputText value="Parça açıklaması" />
				<h:outputText value="Miktar" />
				<h:outputText value="" />
				<h:selectOneMenu value="#{siparisBean.siparisDetay.malzemeId.id}">
					<f:selectItems value="#{siparisBean.selectItemsMalzeme}" />
				</h:selectOneMenu>
				<h:inputText
					value="#{siparisBean.siparisDetay.siparisDetayAciklama}">
				</h:inputText>
				<h:inputText value="#{siparisBean.siparisDetay.miktar}">
				</h:inputText>
				<p:commandButton value="Ekle" update="siparisTable,malzemeDetay"
					actionListener="#{siparisBean.siparisEkle}"></p:commandButton>
			</h:panelGrid>
			<p:commandButton action="#{siparisBean.siparisKayit}" value="Kayıt" />
			<p:commandButton action="#{siparisBean.siparisOnayla}" value="Onayla" />

			<p:dataTable id="siparisTable" var="siparis"
				value="#{siparisBean.siparisDetayList}" rows="10">
				<p:column>
					<f:facet name="header">
                 Malzeme Kodu
            </f:facet>
					<h:outputText value="#{siparis.malzemeId.malzemeAdi}" />
				</p:column>

				<p:column>
					<f:facet name="header">
                   Malzeme Açıklaması
            </f:facet>
					<h:outputText value="#{siparis.siparisDetayAciklama}" />
				</p:column>

				<p:column>
					<f:facet name="header">
                   Miktar
            </f:facet>
					<h:outputText value="#{siparis.miktar}" />
				</p:column>

			</p:dataTable>
		</h:form>
	</h:body>
</f:view>
</html>
